﻿using System.Collections.Generic;
using System.Globalization;

namespace loader
{
    class loc
    {
        private string isocode;
        public bool issupported;
        private Dictionary<string, string> texts;
        public void loadfromtext(string text)
        {
            string[] rows = text.Split(new string[] { "\r\n" }, System.StringSplitOptions.RemoveEmptyEntries);
            string[] item;
            foreach (string row in rows)
            {
                item = row.Split(';');
                if (this.texts.ContainsKey(item[0])) this.texts[item[0]] = item[1];
                else this.texts.Add(item[0], item[1]);
            }
        }
        public loc()
        {
            this.isocode = RegionInfo.CurrentRegion.ThreeLetterISORegionName;
            this.texts = new Dictionary<string, string>();
            switch (this.isocode)
            {
                case "HUN":
                    this.issupported = true;
                    this.loadfromtext(Properties.Resources.hun);
                    break;
                case "GER":
                    this.issupported = true;
                    this.loadfromtext(Properties.Resources.ger);
                    break;
                default:
                    //english ui elements are built in
                    this.issupported = false;
                    this.loadfromtext(Properties.Resources.eng); //english resource is default
                    break;
            }
        }
        public string this[string key]
        {
            get
            {
                return this.texts[key];
            }
        }
    }
}
